﻿Module Module1
    Function Bai11(ByVal n As Integer) As Integer
        Dim T As Integer = 1
        Dim S As Integer = 0
        Dim i As Integer
        For i = 1 To n Step 1
            T = T * i
            S = S + T
        Next
        Return S
    End Function
    Sub Main()
        Dim n As Integer
        Console.WriteLine("Nhap n: ")
        n = Console.ReadLine()
        Dim kq As Integer
        kq = Bai11(n)
        Console.WriteLine("S(n)= " & kq)
    End Sub

End Module
